<?php
//+---------------------------------------------------------------------------------------------------------------------
//| 人生是荒芜的旅行，冷暖自知，苦乐在心
//+---------------------------------------------------------------------------------------------------------------------
//| Author:Janmas <janmas@126.com>
//+---------------------------------------------------------------------------------------------------------------------
//| 
//+---------------------------------------------------------------------------------------------------------------------


namespace app\admin\controller;


use app\admin\validate\UserValidate;
use app\common\event\UserSubscribe;
use think\facade\Event;

class Login extends Admin
{
	protected $noNeedLogin = ['*'];

	public function login(){
		if(session('SYSTEM_ID')){
			return redirect('/admin/index/index');
		}
		if($this->request->isAjax()){
			(new UserValidate())->go($this->request->post(),'login');
			if($this->auth->login($this->request->post('account'),$this->request->post('passwd'))){
				return $this->success('登陆成功','/admin/index/index');
			}else{
				return $this->error('登陆失败');
			}
		}
		return $this->fetch();
	}

	public function logout(){
		session('system_user',null);
		session('SYSTEM_ID',null);
		return redirect('/admin/login/login');
	}
}